package suzf.top.usercenter.data.repository

import rx.Observable
import suzf.top.base.data.net.RetrofitFactory
import suzf.top.base.data.protocol.BaseResp
import suzf.top.usercenter.data.api.UserApi
import suzf.top.usercenter.data.protocol.*
import javax.inject.Inject

/**
 *  用户网络请求
 *========================
 * Created with AndroidStudio
 * Author:Mr.Su
 * Date:2019-09-08
 * Time:14:38
 * ========================
 */
class UserRepository @Inject constructor(){

    /**
     * 注册
     */
    fun register(mobile: String, pwd: String, verifyCode: String): Observable<BaseResp<String>> {
        return RetrofitFactory.instance.create(UserApi::class.java)
                .register(RegisterReq(mobile,pwd,verifyCode))
    }

    /**
     * 登录
     */
    fun login(mobile: String, pwd: String, pushId: String): Observable<BaseResp<UserInfo>> {
        return RetrofitFactory.instance.create(UserApi::class.java)
                .login(LoginReq(mobile,pwd,pushId))
    }

    /**
     * 忘记密码
     */
    fun forgetPwd(mobile: String, verifyCode: String): Observable<BaseResp<String>> {
        return RetrofitFactory.instance.create(UserApi::class.java)
                .forgetPwd(ForgetPwdReq(mobile,verifyCode))
    }

    /**
     * 重置密码
     */
    fun resetPwd(mobile: String, pwd: String): Observable<BaseResp<String>> {
        return RetrofitFactory.instance.create(UserApi::class.java)
                .resetPwd(ResetPwdReq(mobile,pwd))
    }

    /**
     * 修改用户信息
     */
    fun editUser(userIcon: String,userName: String,userGender: String,userSign: String): Observable<BaseResp<UserInfo>> {
        return RetrofitFactory.instance.create(UserApi::class.java)
                .editUser(EditUserReq(userIcon,userName,userGender,userSign))
    }
}